package net.expectx.micro.shop.api.common.util;

import net.expectx.micro.shop.api.common.ApiConstants;
import org.apache.commons.lang.StringUtils;

import javax.servlet.http.HttpServletRequest;

/**
 * @author lijian
 */
public class ApiUtils {
    public static Long getUserId(HttpServletRequest request) {
        String requestCurrentKey = (String) request.getAttribute(ApiConstants.REQUEST_CURRENT_KEY);
        if (StringUtils.isNotEmpty(requestCurrentKey)) {
            return Long.parseLong(requestCurrentKey);
        } else {
            return -1L;
        }
    }
}
